{extend name="base" /}
{block name="body"}
<style type="text/css">
.mleft {
    margin-right: 10px;
}
</style>
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">充值记录</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
             <div class="layui-form-item">
                <form class="layui-form layui-form-pane" action="{:url('/channel/order/index')}" method="get">
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">数据查询</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{:input('keyword')}" placeholder="请输入订单号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline mleft">
                      <label class="layui-form-label">选择游戏</label>
                      <div class="layui-input-inline" style="width: 130px;">
                        <select name="game" lay-filter="game" id="game" lay-search>
                            <option value="">请选择游戏</option>
						    {foreach name="game_list" item="vo"}
							<option value="{$vo.id}"{if condition="$data.game == $vo.id"} selected{/if}>{$vo.name}</option>
							{/foreach}
                        </select>
                      </div>
                    </div>
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">范围选择</label>
                        <div class="layui-input-inline" style="width: 200px;">
                            <input name="starttime" value="{:input('starttime')}" class="layui-input" placeholder="开始时间" id="starttime">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 200px;">
                          <input name="endtime" value="{:input('endtime')}" class="layui-input" placeholder="截止时间" id="endtime">
                        </div>
                    </div>
                    <input type="hidden" name="type" value="order">
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                        <a id="exportBtn" href="#" class="layui-btn">导出</a>
                    </div>
                </form>
              </div>
                <hr>

                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>订单号</th>
                        <th>玩家账号</th>
                        <th>游戏名称</th>
                        <th>充值金额</th>
						<th>充值时间</th>
						<th style="width: 55px">状态</th>
                    </tr>
                    </thead>
                    <tbody>
						{foreach name="pay_list" item="vo"}
						<tr id="tr_{$vo.order_no}">
							<td>{$vo.order_no}</td>
                            <td>{if condition="$vo.gid eq 30"}{:get_old_player($vo['uid'])}{else}{:get_player($vo['uid'],'account')}{/if}</td>
							<td>{$vo.name}</td>
							<td>{$vo.amount}</td>
							<td>{$vo.pay_time}</td>
                            <td>{switch name="$vo['order_status']" }
                            {case value="0"}<font color=red>未支付</font>{/case}
                            {case value="1"}已支付{/case}
                            {case value="2"}已充值{/case}
                            {case value="3"}已发货{/case}
                            {case value="4"}通知游戏失败{/case}
                            {default /}异常
                            {/switch}
                            </td>
						</tr>
						{/foreach}
                    </tbody>
                </table>
                <!--分页-->
				{:$pay_list->render()}
            </div>    
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
layui.use(['jquery','laydate'],function () {
    var laydate = layui.laydate;
    var $ = layui.$;

var startDate = layui.laydate.render({
  elem: '#starttime',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      endDate.config.min.year = date.year;
      endDate.config.min.month = date.month - 1;
      var day = date.date;
      if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
        day = day + 1;
      }else{
        endDate.config.min.hours = date.hours;
        endDate.config.min.minutes = date.minutes;
        endDate.config.min.seconds = date.seconds;
      }
      endDate.config.min.date = day;
      endDate.config.btns = ['clear','confirm'];
    }else{
      endDate.config.min.year = '';
      endDate.config.min.month = '';
      endDate.config.min.date = '';
      endDate.config.min.hours = '';
      endDate.config.min.minutes = '';
      endDate.config.min.seconds = '';
      endDate.config.btns = ['clear','now','confirm'];
    }
  }
});


var endDate = layui.laydate.render({
  elem: '#endtime',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      startDate.config.max.year = date.year;
      startDate.config.max.month = date.month - 1;
      var day = date.date;
      if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
        day = day - 1;
      }else{
        startDate.config.max.hours = date.hours;
        startDate.config.max.minutes = date.minutes;
        startDate.config.max.seconds = date.seconds;
      }
      startDate.config.max.date = day;          
      startDate.config.btns = ['clear','confirm'];
    }else{
      startDate.config.max.year = '';
      startDate.config.max.month = '';
      startDate.config.max.date = '';

      startDate.config.max.hours = '';
      startDate.config.max.minutes = '';
      startDate.config.max.seconds = '';
      startDate.config.btns = ['clear','now','confirm'];
    }
  }
});
});
// 导出
$('#exportBtn').on('click', function() {
    // var formDataArray = $('form').serializeArray();
    $('form').attr('action', '{:url("/channel/export")}').submit();
    $('form').attr('action', '{:url("/channel/order/index")}');
});
</script>
{/block}